/**
 * @description: 文件描述
 * @version: 0.0.1
 * @author: ljr
 * @Date: 2023-09-12 16:35:58
 */

import { Inject, Controller, Body, Post,Get, Query } from '@midwayjs/core';
import { Context } from '@midwayjs/koa';

import { OrdersService } from '../service/orders.service';
import { CreatedOrderDTO, UpdateOrderInfoDTO, CreateOrderCostInfo, UpdateOrderCostInfo } from '../dto/order';
import { PageDTO, IdDTO } from "../dto/common"

@Controller('/api/v1/orders')
export class orderController {
  @Inject()
  ctx: Context;
  @Inject()
  OrdersService: OrdersService;

  /**
    * @summary 创建订单信息
    * @description 创建订单信息
    * @router post /api/v1/user/checkToken
    * @request body orderName  *body
    * @response 200 baseResponse 返回结果
    */
  @Post('/createdOrder')
  async createdOrder(@Body() options: CreatedOrderDTO): Promise<any> {
    return await this.OrdersService.createdOrder(options);
  }

  /**
   * @summary 订单信息分页查询
   * @description 订单信息分页查询
   * @router post /api/v1/orders/getOrderPage
   * @request body pageSize  *body
   * @request body pageNum  *body
   * @request body searchKey  *body
   * @response 200 baseResponse 返回结果
   */
  @Post('/getOrderPage')
  async getOrderPage(@Body() options: PageDTO): Promise<any> {
    return await this.OrdersService.getOrderPage(options);
  }

  /**
   * @summary 删除订单信息
   * @description 删除订单信息
   * @router post /api/v1/orders/delOrderInfo
   * @request body id  *body
   * @response 200 baseResponse 返回结果
   */
  @Get('/delOrderInfo')
  async delOrderInfo(@Query() options: IdDTO): Promise<any> {
    return await this.OrdersService.delOrderInfo(options);
  }

  /**
   * @summary 修改订单信息
   * @description 修改订单信息
   * @router post /api/v1/orders/updateOrderInfo
   * @request body id  *body
   * @response 200 baseResponse 返回结果
   */
  @Post('/updateOrderInfo')
  async updateOrderInfo(@Body() options: UpdateOrderInfoDTO): Promise<any> {
    return await this.OrdersService.updateOrderInfo(options);
  }

  /**
   * @summary 订单数据导入
   * @description 订单数据导入
   * @router post /api/v1/orders/uploadOrdersFile
   * @request body id  *body
   * @response 200 baseResponse 返回结果
   */
  @Post('/uploadOrdersFile')
  async uploadOrdersFile(): Promise<any> {
    // 获取流
    // const stream = this.ctx.files[0];
    return await this.OrdersService.uploadOrdersFile();
  }

  /**
   * @summary 获取订单详情
   * @description 获取订单详情
   * @router post /api/v1/orders/getOrdersDetailsById
   * @request body id  *body
   * @response 200 baseResponse 返回结果
   */
  @Post('/getOrdersDetailsById')
  async getOrdersDetailsById(@Body() options: IdDTO): Promise<any> {
    return await this.OrdersService.getOrdersDetailsById(options);
  }

  /**
   * @summary 查询订单其他成本
   * @description 查询订单其他成本
   * @router post /api/v1/orders/getOrderCostLists
   * @request body id  *body
   * @response 200 baseResponse 返回结果
   */
  @Post('/getOrderCostLists')
  async getOrderCostLists(@Body() options: IdDTO): Promise<any> {
    return await this.OrdersService.getOrderCostLists(options.id);
  }

  /**
   * @summary 新增订单其他成本
   * @description 新增订单其他成本
   * @router post /api/v1/orders/createOrderCostInfo
   * @request body id  *body
   * @response 200 baseResponse 返回结果
   */
  @Post('/createOrderCostInfo')
  async createOrderCostInfo(@Body() options: CreateOrderCostInfo): Promise<any> {
    return await this.OrdersService.createOrderCostInfo(options);
  }

  /**
   * @summary 更新订单其他成本
   * @description 更新订单其他成本
   * @router post /api/v1/orders/updateOrderCostInfo
   * @request body id  *body
   * @response 200 baseResponse 返回结果
   */
  @Post('/updateOrderCostInfo')
  async updateOrderCostInfo(@Body() options: UpdateOrderCostInfo): Promise<any> {
    return await this.OrdersService.updateOrderCostInfo(options);
  }

  /**
   * @summary 删除订单其他成本
   * @description 删除订单其他成本
   * @router post /api/v1/orders/delOrderCostInfo
   * @request body id  *body
   * @response 200 baseResponse 返回结果
   */
  @Post('/delOrderCostInfo')
  async delOrderCostInfo(@Body() options: IdDTO): Promise<any> {
    return await this.OrdersService.delOrderCostInfo(options.id);
  }
}